

public class MyQueue {
	int iSize;
	int iStart;
	int iEnd;
	int iTotal;
	Object oQueue[];

	public MyQueue(int iSize) {

		this.iSize = iSize;
		oQueue = new Object[iSize];
		iStart = 0;
		iEnd = 0;
		iTotal = 0;

	}

	public boolean isEmpty() {

		if (iTotal == 0) {
			return true;
		} else {
			return false;
		}
	}

	public boolean isFull() {

		if (iTotal == iSize) {
			return true;
		} else {
			return false;
		}
	}

	public void in(Object oObject) {
		if (isFull()) {
			System.out.println("The stack is full!");
		} else {
			iTotal++;
			oQueue[iEnd++] = oObject;

			if (iEnd == iSize) {
				iEnd = 0;
			}

		}
	}

	public Object out() {

		if (isEmpty()) {
			System.out.println("The stack is empty!");
			return null;

		} else {

			Object out = oQueue[iStart++];
			iTotal--;
			if (iStart == iSize) {
				iStart = 0;
				
			}
			return out;
		}
	}

	public void show() {	
		
		if (isEmpty()) {
			System.out.println("The stack is empty!");
		} else {
			if (iStart < iEnd) {
				for (int i = iStart; i < iEnd; i++) {
					System.out.print(",");
					System.out.print(oQueue[i]);
				}
			} else {
				for (int i = iStart; i < iSize; i++) {
					System.out.print(",");
					System.out.print(oQueue[i]);
				}
				for (int i = 0; i < iEnd; i++) {
					System.out.print(",");
					System.out.print(oQueue[i]);
				}
			}
		}
	}
}
